import React from 'react';
import ActionButton from './ActionButton';
import { complete } from '../service';
import { ElNotification } from '@/components/el';
import { SubmitCyan } from '@/components/el/ElIcon';
import { withRouter } from 'react-router-dom';

interface Props {
  onBack?: Function;
  history: any;
}
class BackButton extends React.Component<Props> {
  back = () => {
    if (this.props.onBack) {
      this.props.onBack();
    } else {
      this.props.history.go(-1);
    }
  };
  render() {
    return (
      <ActionButton
        text='返回'
        tooltip='返回'
        action={this.back}
        icon={<SubmitCyan />}
      />
    );
  }
}

export default withRouter(BackButton);
